<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateOrderGoodsTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('order_goods', function (Blueprint $table) {
            $table->increments('id');
            $table->integer('order_id');
            $table->integer('user_id');
            $table->integer('goods_id');
            $table->string('goods_name', 255);
            $table->string('goods_thumb', 255)->nullable();
            $table->integer('goods_num')->default(0);
            $table->decimal('goods_price');                           // 商品成交价
            $table->decimal('full_cut_price');                        // 满减优惠价格
            $table->integer('give_integral')->deafult(0);             // 单件商品赠送的积分
            $table->string('spec_key')->nullable();
            $table->string('spec_value')->nullable();
            $table->timestamp('commented_at')->nullable();             // 为空时代表未评论
            $table->string('promotionable_type')->nullable();          // 促销活动类型，针对商品的促销类型
            $table->string('promotionable_id')->default(0);            // 促销活动id
            $table->tinyInteger('status')->default(0);                 // 0未发货，1已发货
            $table->integer('delivery_id')->default(0);                // 发货单id
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('order_goods');
    }
}
